package com.yipinhouse.backstage.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.yipinhouse.backstage.client.ContractManageWebClient;
import com.yipinhouse.backstage.client.param.UploadContractAttachmentWebParam;
import com.yipinhouse.backstage.client.param.UploadContractWebParam;
import com.yipinhouse.common.result.Result;
import com.yipinhouse.signing.client.ContractManageClient;
import com.yipinhouse.signing.client.param.UploadContractAttachmentParam;
import com.yipinhouse.signing.client.param.UploadContractParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
@Slf4j
@RestController
@RequestMapping("backstage")
public class ContractManageWebApiImpl implements ContractManageWebClient {

    @Resource
    private ContractManageClient contractManageClient;

    @Override
    public Result uploadContract(UploadContractWebParam param) {
        UploadContractParam uploadContractParam = BeanUtil.copyProperties(param, UploadContractParam.class);
        Result result = contractManageClient.uploadContract(uploadContractParam);
        return result;
    }

    @Override
    public Result uploadContractAttachment(UploadContractAttachmentWebParam param) throws Exception {
        UploadContractAttachmentParam uploadContractAttachmentParam = BeanUtil.copyProperties(param, UploadContractAttachmentParam.class);
        Result result = contractManageClient.uploadContractAttachment(uploadContractAttachmentParam);
        return result;
    }
}
